package barrier;


import com.ibm.tspaces.TupleSpace;
import com.ibm.tspaces.TupleSpaceException;

public class Client extends Thread{

	private Barrier barrier;
	private int counter;
	
	public Client(boolean init, String tag, TupleSpace space, int counter)
	throws TupleSpaceException
	{
		this.barrier = new Barrier(tag, space);
		this.counter = counter;
		
		if(init)
			barrier.init();
	}
	
	@Override
	public void run() 
	{
		System.out.println("Antes do rendezvous");
		try {
			barrier.barrier(counter);
		} catch (TupleSpaceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("Depois do rendezvous");
	}
	
}
